<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>管理登录</title>

    <!-- Bootstrap -->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">

    <link href="../build/css/custom.min.css" rel="stylesheet">
    <style>
     .identify{position:relative;}
.identify  img{position:absolute;right:10px;top:6px;}
    </style>
  </head>

  <body class="login">
    <div>
      <a class="hiddenanchor" id="signup"></a>
      <a class="hiddenanchor" id="signin"></a>

      <div class="login_wrapper">
        <div class="animate form login_form">
          <section class="login_content">
            <form>
              <h1>后台登录</h1>
              <div>
                <input type="text" class="form-control" placeholder="用户名" required=""   id="loginName" style="padding:8px  12px;" />
              </div>
              <div>
                <input type="password" class="form-control" placeholder="密码" required=""  id="loginPassword"  style="padding:8px  12px;" />
              </div>
              <div  class="identify">
                  <input type="text"  placeholder="验证码"  style="padding:8px  12px;"  id="yzmtext">
                  <img src="/sys/code" alt=""  id="radimgcode">
              </div>
              <div>
                <a class="btn btn-default submit" style="padding:8px  40px;"   id="loginBtn">登录</a>
                <!-- <a class="reset_pass" href="#">Lost your password?</a> -->
              </div>

              <div class="clearfix"></div>

             
            </form>
          </section>
        </div>

        
      </div>
    </div>
    <script src="../vendors/jquery/dist/jquery.min.js"></script>
    <script>
        (function(){
          $("#radimgcode").click(function(){
                $("#radimgcode").attr("src", "/sys/code?rand="+ ( +new Date) );

            });

          $("#loginBtn").click(function(){
               doLogin()
          });

          $(document).keydown(function(ev){
            if( ev.keyCode==13)
            {
              doLogin();
            }
        });
        
        function  doLogin(){
            var uname = $("#loginName").val();
            var upwd = $("#loginPassword").val();
            var yzm = $("#yzmtext").val();
            if( !uname )
            {
              $("#loginName").focus();
              return false;
            }
            if( !upwd )
            {
              $("#loginPassword").focus();
              return false;
            }
            if( !yzm )
            {
              $("#yzmtext").focus();
              return false;
            }
            $.ajax({
               type:"post",
               url:"/admin/login",
               data:{username:uname,password:upwd,code:yzm},
               success:function( info ){
                   var code = info.code;
                   var desc = info.desc;
                   if( code == 1 )
                   {
                      location.href = "jingzuticket.html";
                   }
                   else
                   {
                       alert(desc);
                   }
                
               }

            });
        }
    
    
    
        }());
      </script>
  </body>
 
</html>
